import http from "./request"

export const roleList = (params: IroleList): RES<IroleListData> => http.get("role/list", { params })

export const roleListAll = (): RES<roleList[]> => http.get("role/listAll")

//添加分配角色 /role/create
export const roleCreate = (data: IAllocationParamsModel): RES<number> => {
  return http({
    url: `/role/create`,
    method: "POST",
    data
  })
}
// 编辑分配角色
export const allocationById = (data: IAllocationParamsModel): RES<number> => {
  return http({
    url: `role/update/${data.id}`,
    method: "POST",
    data
  })
}

// 修改角色状态
export const updateRoleStatusById = (params: { id: number, status: string }): RES<number> => {
  return http({
    url: `/role/updateStatus/${params.id}`,
    method: "POST",
    params
  })
}

// 根据id获取用户角色菜单列表
export const getRoleAlloctionMenus = (id: string): RES<IAllocMenuResultModel[]> => {
  return http({
    url: `role/listMenu/${id}`
  })
}

//获取所有菜单列表 
export const roleTreeList = (): RES<IRoleMenuModel[]> => http.get("/menu/treeList")
//分配菜单 /role/allocMenu
export const roleAlloMenu = (menuIds: number[], roleId: number): RES<number> => http.post(`/role/allocMenu?menuIds=${menuIds}&roleId=${roleId}`)

//获取所有后台资源分类
export const resourceCategoryAll = (): RES<any> => http.get("resourceCategory/listAll")
//获取所有后台资源
export const resourceAll = (): RES<any> => http.get("/resource/listAll")